from apps.common.base.serializers import *
from apps.education.courseStudent.models import *
from apps.education.student.serializers import StudentBaseSerializer
from apps.education.course.serializers import CourseModelSerializer

class CourseStudentBaseSerializer(BaseSerializer):
    class Meta:
        model = CourseStudent
        fields = "__all__"


class CourseStudentModelSerializer(CourseStudentBaseSerializer):

    courseModel = serializers.SerializerMethodField()
    def get_courseModel(self, obj):
        try:
            return CourseModelSerializer(obj.course).data
        except:
            return {}
        
    studentModel = serializers.SerializerMethodField()
    def get_studentModel(self, obj):
        try:
            return StudentBaseSerializer(obj.student).data
        except:
            return {}
        
    class Meta:
        model = CourseStudent
        fields = "__all__"
